package com.ymttest.business.data.socket;

import io.socket.client.Ack;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;

import java.net.URISyntaxException;
import java.util.Optional;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import net.sf.json.JSONException;
import net.sf.json.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ServerConnection {

//    private static final Logger logger = LoggerFactory.getLogger(DefaultSocketIo.class);
//    private String url;
//    private IO.Options options;
//    private Socket socket;
//    private String socketId;
//    
//    public void shouldAcceptAQueryStringOnDefaultNamespace() throws URISyntaxException, InterruptedException, JSONException {
//	 final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
//
//     socket = client("c=d");
//     socket.emit("getHandshake", new Ack() {
//         public void call(Object... args) {
//             JSONObject handshake = (JSONObject)args[0];
//             values.offer(Optional.ofNullable(handshake));
//         }
//     });
//     socket.connect();
//    }
//    
//    
//    
//    public void shouldAcceptAQueryString() throws URISyntaxException, InterruptedException, JSONException {
//        final BlockingQueue<Optional> values = new LinkedBlockingQueue<Optional>();
//
//        socket = client("/abc?b=c&d=e");
//        socket.on("handshake", new Emitter.Listener() {
//            @Override
//            public void call(Object... args) {
//                JSONObject handshake = (JSONObject)args[0];
//                values.offer(Optional.ofNullable(handshake));
//            }
//        });
//        socket.connect();
//
//        @SuppressWarnings("unchecked")
//        Optional<JSONObject> handshake = values.take();
//        JSONObject query = handshake.get().getJSONObject("query");
////        assertThat(query.getString("b"), is("c"));
////        assertThat(query.getString("d"), is("e"));
//
//        socket.disconnect();
//    }
}
